package com.maxus.mini.backend.open.api.controller.lib;

import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.maux.mini.data.api.lib.LibService;
import com.maux.mini.data.api.redis.RedisService;
import com.maxus.mini.backend.open.api.controller.BaseController;
import com.maxus.mini.backend.open.api.vo.req.P800003Vo;
import com.maxus.mini.backend.open.api.vo.res.PR800003Vo;
import com.maxus.mini.common.PageImplE;
import com.maxus.mini.common.utils.BeanUtilsExtended;
import com.maxus.mini.common.vo.ResBody;
import com.maxus.mini.entity.lib.Lib;
import com.maxus.mini.entity.user.User;
import com.maxus.mini.entity.vo.lib.LibVo;

/**
 * 收藏controller
 * 
 * @author wujinsong
 *
 */
@RestController()
@RequestMapping(value = "/api/v1.0/lib")
public class LibController extends BaseController {
	@Reference(version = "1.0.0")
	private LibService<User, User> libService;
	@Reference(version = "1.0.0")
	private RedisService redisService;

	/**
	 * 收藏列表
	 * 
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "list", method = { RequestMethod.POST })
	@ResponseBody()
	public ResBody list(@RequestBody P800003Vo req) {
		PR800003Vo retVo = new PR800003Vo();
		List<Lib> list = null;

		LibVo vo = new LibVo();
		try {
			BeanUtilsExtended.copyProperties(vo, req);
			PageImplE<Lib> pageImplE = libService.page(vo);
			list = pageImplE.getContent();
			retVo.setTotalElements(pageImplE.getTotalElements());
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}

		retVo.setItemVos(list);

		return retVo;
	}
}
